<template>
  <div class="student">
    <div class="search-box">
      <div class="search-item">
        <span>学员姓名</span>
        <el-input v-model="keyName" clearable style="width:200px;" />
      </div>
      <div class="search-item">
        <span>学员编号</span>
        <el-input v-model="keyNum" clearable style="width:200px;" />
      </div>
      <div class="search-item">
        <span>最近上课时间</span>
        <el-date-picker
          v-model="keyTime"
          type="datetimerange"
          range-separator="至"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
        />
        <el-button type="primary" icon="el-icon-search">筛选</el-button>
      </div>
    </div>
    <el-table
      :data="studentTableData.slice((currentPage-1)*pageSize,currentPage*pageSize)"
      border
      style="width: 100%;"
    >
      <el-table-column prop="studentName" label="学员姓名" align="center">
        <template slot-scope="scope">
          <el-button
            type="text"
            @click="goStudentInfo(scope.row.studentNum)"
          >{{ scope.row.studentName }}</el-button>
        </template>
      </el-table-column>
      <el-table-column prop="studentStatus" label="学员状态" align="center" />
      <el-table-column prop="studentNum" label="学员编号" align="center" />
      <el-table-column prop="client" label="客户" align="center" />
      <el-table-column prop="contact" label="联系方式" align="center" />
      <el-table-column prop="hour" label="课时" align="center" />
      <el-table-column prop="validity" label="有效期" align="center" />
      <el-table-column prop="classTime" label="最近上课时间" align="center" />
    </el-table>
    <div class="block" style="margin:20px 0;">
      <el-pagination
        :current-page="currentPage"
        :page-sizes="[5, 10, 20]"
        :page-size="pageSize"
        :total="studentTableData.length"
        background
        layout="total, sizes, prev, pager, next, jumper"
        @current-change="handleCurrentChange"
        @size-change="handleSizeChange"
      />
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      keyName: '',
      keyNum: '',
      keyTime: '',
      studentTableData: [
        {
          id: '1',
          studentName: '刘德华',
          studentStatus: '',
          studentNum: 'S2019080515',
          client: '',
          contact: '15811583698',
          hour: '0/0',
          validity: '-',
          classTime: '2019-06-03'
        }
      ],
      currentPage: 1,
      pageSize: 5
    }
  },
  methods: {
    handleCurrentChange(val) {
      this.currentPage = val
    },
    handleSizeChange(val) {
      this.pageSize = val
    },
    goStudentInfo(studentNum) {
      this.$router.push({ name: 'Studentinfo', params: { 'studentNum': studentNum }})
    }
  }
}
</script>

<style lang="scss" scoped>
.student {
  padding: 20px;
  .search-box {
    display: flex;
    margin: 20px 0;
    .search-item {
      margin-right: 20px;
    }
  }
}
</style>
